<!DOCTYPE html>
<html>

<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=9; IE=8; IE=7; IE=EDGE">
	<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
	<title>个人注册</title>


    <link rel="stylesheet" type="text/css" href="/css/webbase.css" />
    <link rel="stylesheet" type="text/css" href="/css/pages-register.css" />
</head>

<body>
	<div class="register py-container ">
		<!--head-->
		<div class="logoArea">
			<a href="" class="logo-bd"></a>
		</div>
		<!--register-->
		<div class="registerArea">
			<h3>注册新用户<span class="go">我有账号，去<a href="/userController/toLogin" target="_blank">登陆</a></span></h3>
			<div class="info">
				<form class="sui-form form-horizontal" id="myForm" onsubmit="return register()">
					<div class="control-group">
						<label class="control-label">用户名：</label>
						<div class="controls">
							<input type="text" name="username" id="username" placeholder="请输入你的用户名" class="input-xfat input-xlarge">
							<span id="namethis"></span><br>
						</div>
					</div>
					<div class="control-group">
						<label for="inputPassword" class="control-label">登录密码：</label>
						<div class="controls">
							<input type="password" name="password" id="password" placeholder="设置登录密码" class="input-xfat input-xlarge">
						</div>
					</div>
					<div class="control-group">
						<label for="inputPassword" class="control-label">确认密码：</label>
						<div class="controls">
							<input type="password" name="aginPwd" id="aginPwd" placeholder="再次确认密码" onblur="run()" class="input-xfat input-xlarge">
							<span id="pwdtishi"></span><br>
						</div>
					</div>
					<div class="control-group">
						<label for="inputPassword" class="control-label">email：</label>
						<div class="controls">
							<input type="text" name="email" placeholder="请输入邮箱" class="input-xfat input-xlarge">
						</div>
					</div>
					<div class="control-group">
						<label class="control-label">手机号：</label>
						<div class="controls">
							<input type="text" name="phone" id="phone" placeholder="请输入你的手机号"onblur="phonethis()" class="input-xfat input-xlarge">
							<span id="phonehtml"></span><br>
						</div>
					</div>
					<div class="control-group">
						<label for="inputPassword" class="control-label">短信验证码：</label>
						<div class="controls">
							<input type="text" placeholder="短信验证码" id="phoneCode" class="input-xfat input-xlarge">  <a href="javascript:phoneMessage()">获取短信验证码</a>
						</div>
					</div>
					
					<div class="control-group">
						<label for="inputPassword" class="control-label">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</label>
						<div class="controls">
							<input name="m1" type="checkbox" value="2" checked=""><span>同意协议并注册《东东商城用户协议》</span>
						</div>
					</div>
					<div class="control-group">
						<label class="control-label"></label>
						<div class="controls btn-reg">
							<a class="sui-btn btn-block btn-xlarge btn-danger" onclick="register()" target="_blank">完成注册</a>
						</div>
					</div>
				</form>
				<div class="clearfix"></div>
			</div>
		</div>
		<!--foot-->
		<div class="py-container copyright">
			<ul>
				<li>关于我们</li>
				<li>联系我们</li>
				<li>联系客服</li>
				<li>商家入驻</li>
				<li>营销中心</li>
				<li>手机东东商城</li>
				<li>销售联盟</li>
				<li>东东商城社区</li>
			</ul>
			<div class="address">地址：北京市昌平区沙阳路18号 邮编：100000 电话：400-0123-302</div>
			<div class="beian">京ICP备08006666号京公网安备11010888888
			</div>
		</div>
	</div>


<script type="text/javascript" src="/js/plugins/jquery/jquery.min.js"></script>
<script type="text/javascript" src="/js/plugins/jquery.easing/jquery.easing.min.js"></script>
<script type="text/javascript" src="/js/plugins/sui/sui.min.js"></script>
<script type="text/javascript" src="/js/plugins/jquery-placeholder/jquery.placeholder.min.js"></script>
<script type="text/javascript" src="/js/pages/register.js"></script>
</body>

</html>
<script type="text/javascript">
	function phoneMessage(){
		var phone = $("#phone").val();
		if(phone == null || phone.length < 11){
			alert("请填写正确的手机号");
			return ;
		}
		var op = $("#phone").val();
		if (!(/^1(3|4|5|7|8)\d{9}$/.test(op))) {
			$("#phonehtml").html("请输入有效合法的手机号码!");
			$("#phonehtml").css("color","green");
			return false;
		}
		$.ajax({
			url:"/phoneController/phoneMessage",
			type:"post",
			data:{phone:phone},
			dataType:"json",
			success:function (result){
				if(result.code == 100){
					alert(result.message);
				}
				if(result.code == 101){
					alert(result.message);
				}
			},
			error:function (){
				alert("异常");
			}
		})
	}

	var reg = /^\s*$/;//正则判断是否为空
	function register(){
		var str = $("#username").val();//用户名
		var pwd = $("#password").val();//第一个密码
		var anmipwd = $("#aginPwd").val();//第二个密码
		if(reg.test(str)){
			$("#namethis").html("用户名不能为空!");
			$("#namethis").css("color","green");
			return false;
		}
		if(reg.test(pwd)){
			alert("用户名或密码不能为空不能为空");
			return false;
		}
		if(reg.test(anmipwd)){
			alert("用户名或密码不能为空不能为空");
			return false;
		}
		if(pwd != anmipwd){
			alert("密码不一致");
			$("#pwdtishi").html("两次输入密码不一致!");
			$("#pwdtishi").css("color","green");
			return false;
		}
		var op = $("#phone").val();
		if (!(/^1(3|4|5|7|8)\d{9}$/.test(op))) {
			$("#phonehtml").html("请输入有效合法的手机号码!");
			$("#phonehtml").css("color","green");
			return false;
		}
		$.ajax({
			url:"/userController/register",
			type:"post",
			data:$("#myForm").serialize() +"&phoneCode=" + $("#phoneCode").val(),
			dataType: "json",
			success:function (result){
				if(result.code == 100){
					alert(result.message);
				}
				if(result.code == 101){
					alert(result.message);
				}

			},
			error:function (){
				alert("注册失败");
			}
		})
	}
</script>